<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html lang="zh-CN">

<%@include file="/WEB-INF/include-head.jsp" %>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <%@include file="/WEB-INF/include-nav.jsp" %>
</nav>

<script type="application/javascript" src="crowd/my-role.js"></script>

<%--引入boottrap模型，用作新增用户的弹窗--%>
<%@include file="/WEB-INF/model-role-add.jsp" %>
<%--引入boottrap模型，用作更新用户的弹窗--%>
<%@include file="/WEB-INF/model-role-edit.jsp" %>
<%--引入boottrap模型，用作删除用户的弹窗--%>
<%@include file="/WEB-INF/model-role-delete.jsp" %>
<%--引入ztree树，用作权限控制的窗体--%>
<%@include file="/WEB-INF/modal-role-assign-auth.jsp" %>

<script type="text/javascript" src="jquery/jquery.pagination.js"></script>
<link rel="stylesheet" href="ztree/zTreeStyle.css"/>
<script type="text/javascript" src="ztree/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="crowd/my-role.js"></script>

<script type="application/javascript">
    $(function () {
        // 1.为分页操作准备初始化数据
        window.pageNum = 1;
        window.pageSize = 5;
        window.keyword = "";
        // 2.调用执行分页的函数，显示分页效果
        generatePage();

        // 3.给查询按钮绑定单击响应事件
        $("#btnSearch").click(function () {
            // 获取关键字数据赋值给对应的全局变量
            window.keyword = $("#inputMessage").val();

            // 调用分页函数，刷新页面
            generatePage();
        });

        // 4.点击新增按钮打开模态框
        $("#showAddModalBtn").click(function () {
            $("#addModal").modal("show");
        });

        // 13.给分配权限按钮绑定单击响应函数    打开模态框
        $("#rolePageBody").on("click",".checkBtn",function(){
            // 需要先将roleId拿到，否则调用fillAuthTree将会没有roleId的值
            window.roleId = this.id;
            $("#assignModal").modal("show");
            // 在模态框中装载树 Auth 的形结构数据
            fillAuthTree();
        });
    });

</script>

<div class="container-fluid">

    <%@include file="/WEB-INF/include-sidebar.jsp" %>

    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 数据列表</h3>
            </div>
            <div class="panel-body">
                <div style="float:left;">
                    <div class="form-group has-feedback">
                        <div class="input-group">
                            <div class="input-group-addon">查询条件</div>
                            <input class="form-control has-success" name="keyword" id="inputMessage" style="width:40%"
                                   type="text"
                                   placeholder="请输入查询条件">
                            <button id="btnSearch" style="float:left;margin-left:10px;" class="btn btn-warning"><i
                                    class="glyphicon glyphicon-search"></i> 查询
                            </button>
                            <button type="button" class="btn btn-danger" style="float:right;margin-left:10px;">
                                <i class=" glyphicon glyphicon-remove"></i> 删除
                            </button>
                            <button type="button" id="showAddModalBtn" class="btn btn-primary" style="float: right;">
                                <i class="glyphicon glyphicon-plus"></i> 新增
                            </button>
                        </div>
                    </div>
                    <hr style="clear:both;">
                    <div class="table-responsive">
                        <table class="table  table-bordered">
                            <thead>
                            <tr>
                                <th width="30">#</th>
                                <th width="30"><input type="checkbox"></th>
                                <th>名称</th>
                                <th width="100">操作</th>
                            </tr>
                            </thead>
                            <tbody id="rolePageBody"></tbody>
                            <tfoot>
                            <tr>
                                <td colspan="6" align="center">
                                    <div id="Pagination" class="pagination"><!-- 这里显示分页 --></div>
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>